package filters;

import java.io.File;
import java.util.Iterator;
import java.util.TreeSet;

public class isReadableFilter extends AbstractStringFilter {
	
	protected isReadableFilter() {
		_resultSet = new TreeSet<File>();
	}

	public boolean validateParameter(String parameter) {
		return(parameter.compareTo("YES")!=0 || parameter.compareTo("NO")!=0);
	}
	
	public TreeSet<File> filter(TreeSet<File> global,String parameter){
		
		if(parameter.compareTo("YES")==0) {
			for(Iterator<File> it1=global.iterator();it1.hasNext();) {
				File _tmpFile = it1.next();
				if(_tmpFile.canRead()) {
					_resultSet.add(_tmpFile);
				}
			}
		}
		
		if(parameter.compareTo("NO")==0) {
			for(Iterator<File> it1=global.iterator();it1.hasNext();) {
				File _tmpFile = it1.next();
				if(!_tmpFile.canRead()) {
					_resultSet.add(_tmpFile);
				}
			}
		}
		return _resultSet;
	}
	
}
